package net.mikoo.seals.api.security;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import net.mikoo.seals.model.Party;

public class CustomUserDetails implements UserDetails {

	/**
	 * 
	 */
	private static final long serialVersionUID = 422924190655110425L;
	
	private Party party;
	
	protected List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
	public CustomUserDetails() {
	}

	
    public CustomUserDetails(Party party) {
        this.party = party;
    }

	@Override
	public Collection<GrantedAuthority> getAuthorities() {
		return grantedAuthorities;
	}

	@Override
	public String getPassword() {
		return this.party.getUserLogin().getCurrentPassword();
	}


	@Override
	public String getUsername() {
		return this.party.getUserLoginId();
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}

	public Party getParty() {
		return party;
	}

	public void setParty(Party party) {
		this.party = party;
	}
}
